/*
 * FilePath     : \src\router\index.ts
 * Author       : SJZ
 * Date         : 2025-03-12 19:28
 * LastEditors  : SJZ
 * LastEditTime : 2025-03-13 00:23
 * Description  : 路由
 * CodeIterationRecord:
 */

import { createRouter, createWebHistory } from "vue-router";
import navigation from "./navigation";
import type { App } from "vue";

export const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      redirect: "/home"
    },
    {
      path: "/mainLayout",
      name: "mainLayout",
      component: () => import("@/views/mainLayout/index.vue"),
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("@/views/home/index.vue"),
          meta: { withoutTag: true }
        },
        {
          path: "/products",
          name: "products",
          component: () => import("@/views/products/index.vue"),
          meta: { withoutTag: true }
        },
        {
          path: "/about",
          name: "about",
          component: () => import("@/views/about/index.vue"),
          meta: { withoutTag: true }
        },
        {
          path: "/contact",
          name: "contact",
          component: () => import("@/views/contact/index.vue"),
          meta: { withoutTag: true }
        },
        {
          path: "/news",
          name: "news",
          component: () => import("@/views/news/index.vue"),
          meta: { withoutTag: true }
        },
        {
          path: "/help",
          name: "help",
          component: () => import("@/views/help/index.vue"),
          meta: { withoutTag: true }
        }
      ]
    }
  ]
});
// 安装vue路由
export const installRouter = async (app: App) => {
  // 添加路由守卫
  // navigation.set(router);
  app.use(router);
  await router.isReady();
};
